using System;
using System.Net.Mail;
using System.Collections.Generic;
using System.Text;
using System.Xml;

namespace Lds.Ward.PhotoDirectory.Logic
{
	public class FamilyMember
	{
		public FamilyMember() { }
		public FamilyMember(string givenNames, PhoneNumber phone, bool dependent)
		{
			GivenNames = givenNames;
			Telephone = phone;
			Dependent = dependent;
		}
		private string givenNames;

		public string GivenNames
		{
			get { return givenNames; }
			set { givenNames = value; }
		}

		private Gender gender;

		public Gender Gender
		{
			get { return gender; }
			set { gender = value; }
		}

		private PhoneNumber telephone;

		public PhoneNumber Telephone
		{
			get { return telephone; }
			set { telephone = value; }
		}

		private MailAddress email;

		public MailAddress Email
		{
			get { return email; }
			set { email = value; }
		}

		private bool dependent;

		public bool Dependent
		{
			get { return dependent; }
			set { dependent = value; }
		}

		public override string ToString()
		{
			return string.Format("{0} {1} {2} {3}", GivenNames, Gender, Telephone, Email);
		}

		public void ToXml(XmlWriter writer)
		{
			writer.WriteStartElement("member");
			Family.WriteAttribute(writer, "name", GivenNames);
			Family.WriteAttribute(writer, "email", Email);
			Family.WriteAttribute(writer, "phone", Telephone);
			Family.WriteAttribute(writer, "gender", Gender);
			Family.WriteAttribute(writer, "dependent", Dependent);
			writer.WriteEndElement();
		}
	}

	public enum Gender : byte
	{
		Male = (byte)'M',
		Female = (byte)'F',
	}
}
